//
//  OPLoginTextField.h
//  OpenPractice
//
//  Created by red on 2023/10/11.
//  Copyright © 2023 tanyuehong. All rights reserved.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN


@class OPLoginTextField;
@protocol YKLoginTextFieldDelegate <UITextFieldDelegate>

@optional
- (void)textField:(UITextField *)textField didChangeText:(NSString *)text;
- (void)textFieldDidBeginEditing:(UITextField *)textField;
- (void)textFieldDidEndEditing:(UITextField *)textField;
@end

@interface OPLoginTextField : UITextField

@property (nullable, nonatomic, weak) id<YKLoginTextFieldDelegate> textDelegate;

@property (nonatomic, assign) BOOL showClearButton;
@property (nonatomic, assign) BOOL showBottomLine;
@property (nonatomic, assign, readonly) BOOL isTextValid;
@property (nonatomic, assign) UIEdgeInsets hitInsets;
@property (nonatomic, strong, readonly) UIButton *clearButton;
@property (nonatomic, strong, readonly) UIView *clearButtonMask;

- (instancetype)initWithText:(NSString *)text placeholder:(NSString *)placeholder NS_DESIGNATED_INITIALIZER;

- (NSInteger)cursorPosition;
- (BOOL)isCursorAtEnd;

@end

@interface LoginPhoneTextField : OPLoginTextField

- (instancetype)initWithPhone:(NSString *)phone;

@end

@interface LoginPasswordTextField : OPLoginTextField

@property (nonatomic, assign) BOOL showSecurityButton;

@end

@interface LoginCodeTextField : OPLoginTextField

@property (nonatomic, strong) UIButton *sendCodeButton;

- (instancetype)initWithSendCodeTarget:(id)target selector:(SEL)selector;

- (void)setTimeLeft:(NSInteger)timeLeft canSendCode:(BOOL)canSendCode isResendCode:(BOOL)isResendCode;

@end

NS_ASSUME_NONNULL_END
